<template>
  <el-dialog :visible.sync="showPointDialog" :before-close="check" title="提示" width="30%">
    <el-form style="margin-top: -20px;">
      <el-form-item label="退订金额" label-width="100px">
        <el-input
          v-model="outPrice"
          size="mini"
          style="width:50%"
        />
      </el-form-item>
      <el-form-item label="备注" label-width="100px">
        <el-input
          v-model="outRemark"
          size="mini"
          type="textarea"
          style="width:50%"
        />
      </el-form-item>
    </el-form>
    <div class="btn">
      <el-button size="mini" type="primary" round @click="sureBtn">确定</el-button>
      <el-button size="mini" type="primary" plain round @click="check">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { cancelDings } from '@/api/buyList.js'
import { onlyNum } from '@/utils/validate.js'
export default {
  name: 'Watch',
  props: {
    cancelDialog: {
      type: Boolean,
      default: false
    },
    numArr: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      showPointDialog: false, // 遮罩
      ednTime: '',
      outRemark: '',
      outPrice: '',
      oNumber: '', // 订单编号
      orderTime: '', // 订购时间
      orderType: '', // 订单类型
      status: '', // 订单状态
      beginTime: '', // 生效时间
      payPrice: '', // 花费价格
      terminalType: '', // 终端类型
      payCode: '', // 支付渠道编码
      userId: '', // 用户编号
      phoneNumber: '', // 手机号
      reference: '', // 推荐人
      giftCode: '', // 礼品码
      pCode: '', // 产品编号
      pName: '', // 产品名称
      info: {},
      pId: '',
      endTime: '',
      sourceId: '',
      sourceName: '',
      numArrs: '',
      productExistsStatus: '' // 是否在线
    }
  },
  watch: {
    cancelDialog(newVal) {
      this.showPointDialog = newVal
      this.numArrs = this.numArr
    }
  },
  methods: {
    // 回调父组件
    check(val) {
      this.showPointDialog = false
      this.outRemark = ''
      this.outPrice = ''
      this.$emit('closeCancel', val)
    },
    sureBtn() {
      var data = {
        orderForms: [this.numArrs],
        outRemark: this.outRemark,
        outPrice: this.outPrice
      }
      if (this.outPrice && !onlyNum(this.outPrice)) {
        this.$message({
          message: '退款金额为数字',
          type: 'error'
        })
        return false
      }
      cancelDings(data).then(res => {
        if (res.resultCode === '0000') {
          this.$message({
            type: 'success',
            message: '取消成功'
          })
          this.check(true)
        }
      })
    }
  }
}
</script>
<style scoped>

</style>

<style>
.el-form-item__label{
  line-height: 39px !important;
}
.btn{
  margin-top: 20px;
  width: 100%;
  display: flex;
  justify-content: center;
}
</style>

